package com.zrgj.services;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zrgj.entity.Goods;
import com.zrgj.entity.Stock;
import com.zrgj.mapper.StockMapper;
import com.zrgj.vo.StockVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class StockServiceInpl {

    @Resource
    private StockMapper stockMapper;

    public List<Stock> query(StockVO stock ){

        Page page= PageHelper.startPage(stock.getPageNum(), stock.getPageSize(), true);
        //pagehelper内置的类
        String keyword=stock.getKeyword();
        if (keyword!=null&&!"".equals(keyword)){
            keyword="%"+keyword+"%";
            stock.setKeyword(keyword);
        }
//        PageHelper.startPage(2,3);
        List list=stockMapper.queryPyCdName(stock);
        PageInfo<Stock> pageInfo=new PageInfo<Stock>(list,page.getPages());



//        List list2=stockMapper.queryPyCdName(stock);
        return list;
    }

}
